import Main;
import nme.Assets;


class ApplicationMain {
	
	static var mPreloader:NMEPreloader;

	public static function main () {
		
		var call_real = true;
		
		
		var loaded:Int = nme.Lib.current.loaderInfo.bytesLoaded;
		var total:Int = nme.Lib.current.loaderInfo.bytesTotal;
		
		if (loaded < total || true) /* Always wait for event */ {
			
			call_real = false;
			mPreloader = new NMEPreloader();
			nme.Lib.current.addChild(mPreloader);
			mPreloader.onInit();
			mPreloader.onUpdate(loaded,total);
			nme.Lib.current.addEventListener (nme.events.Event.ENTER_FRAME, onEnter);
			
		}
		
		
		if (call_real)
			Main.main();
	}

	static function onEnter (_) {
		
		var loaded:Int = nme.Lib.current.loaderInfo.bytesLoaded;
		var total:Int = nme.Lib.current.loaderInfo.bytesTotal;
		mPreloader.onUpdate(loaded,total);
		
		if (loaded >= total) {
			
			mPreloader.onLoaded();
			nme.Lib.current.removeEventListener(nme.events.Event.ENTER_FRAME, onEnter);
			nme.Lib.current.removeChild(mPreloader);
			mPreloader = null;
			
			Main.main ();
			
		}
		
	}

	public static function getAsset (inName:String):Dynamic {
		
		
		if (inName=="assets/Dragon.png")
			 
            return Assets.getBitmapData ("assets/Dragon.png");
         
		
		if (inName=="assets/DwarfHammer.png")
			 
            return Assets.getBitmapData ("assets/DwarfHammer.png");
         
		
		if (inName=="assets/DwarfSword.png")
			 
            return Assets.getBitmapData ("assets/DwarfSword.png");
         
		
		if (inName=="assets/Ghost.png")
			 
            return Assets.getBitmapData ("assets/Ghost.png");
         
		
		if (inName=="assets/Goblin.png")
			 
            return Assets.getBitmapData ("assets/Goblin.png");
         
		
		if (inName=="assets/Lich.png")
			 
            return Assets.getBitmapData ("assets/Lich.png");
         
		
		if (inName=="assets/PArrow.png")
			 
            return Assets.getBitmapData ("assets/PArrow.png");
         
		
		if (inName=="assets/PDagger.png")
			 
            return Assets.getBitmapData ("assets/PDagger.png");
         
		
		if (inName=="assets/PHammer.png")
			 
            return Assets.getBitmapData ("assets/PHammer.png");
         
		
		if (inName=="assets/PSword.png")
			 
            return Assets.getBitmapData ("assets/PSword.png");
         
		
		if (inName=="assets/Snake.png")
			 
            return Assets.getBitmapData ("assets/Snake.png");
         
		
		if (inName=="assets/TArrow.png")
			 
            return Assets.getBitmapData ("assets/TArrow.png");
         
		
		if (inName=="assets/TFireball.png")
			 
            return Assets.getBitmapData ("assets/TFireball.png");
         
		
		if (inName=="assets/tileWall.png")
			 
            return Assets.getBitmapData ("assets/tileWall.png");
         
		
		if (inName=="assets/wabbit_alpha.png")
			 
            return Assets.getBitmapData ("assets/wabbit_alpha.png");
         
		
		if (inName=="assets/WomanBow.png")
			 
            return Assets.getBitmapData ("assets/WomanBow.png");
         
		
		if (inName=="assets/WomanDagger.png")
			 
            return Assets.getBitmapData ("assets/WomanDagger.png");
         
		
		if (inName=="assets/Zombie.png")
			 
            return Assets.getBitmapData ("assets/Zombie.png");
         
		
		
		return null;
		
	}
	
}



	
		class NME_assets_dragon_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_dwarfhammer_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_dwarfsword_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_ghost_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_goblin_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_lich_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_parrow_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_pdagger_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_phammer_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_psword_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_snake_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_tarrow_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_tfireball_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_tilewall_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_wabbit_alpha_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_womanbow_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_womandagger_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	

	
		class NME_assets_zombie_png extends nme.display.BitmapData { public function new () { super (0, 0); } }
	
